import greenfoot.*;

/**
 * This class defines a crab. Crabs live on the beach.
 */
public class Crab extends Actor
{
    public void act()
    {
        move(3);
        turnAtEdge();
        keycontrol();
        eat2();
    }
    
    public void turnAtEdge(){
        if(isAtEdge()){
        turn(10);
        }

    }
    
    public void keycontrol(){
        if(Greenfoot.isKeyDown("left")){
          turn(-10);
        }
        if(Greenfoot.isKeyDown("right")){
          turn(10);
        }
    }
   
    public void eat2(){
        if(isTouching(Lobster.class)){
          removeTouching(Lobster.class);
        }
    }
}
    

